<?php
	 require_once ("db_connection.php");
	
	$id = "RS-" . uniqid();
	$ralimorateid = $_POST['ralimorateid'];
	$services = mysql_real_escape_string($_POST["services"]);
	$remarks = mysql_real_escape_string($_POST["remarks"]);
	
	$result = mysql_query("SELECT * FROM ralimorates WHERE id = '$ralimorateid'", $con);
	$row = mysql_fetch_array($result, MYSQL_ASSOC);
	$cityname = $row['cityname'] ;
	
	
	$query = "INSERT INTO ralimorateservices(id,cityname, ralimorateid, services,remarks)
		VALUES('$id','$cityname', '$_POST[ralimorateid]', '$services', '$remarks')";
	
	if(!mysql_query($query, $con)) {
		die('Error: '. mysql_error());
	}
	
	$data = array("Saved!", $id);
	
	mysql_close($con);
	
	echo json_encode($data);
	flush();
?>